<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>材料管理</title>
<%@ include file="/module/js.jsp"%>
</head>
<body>
	<form action="#" name="Form" id="Form" method="post">
	    <input type="hidden" name="id" id="id"  value="${id}" /> 
		<input type="hidden" name="idList" id="idList"/>
		<table cellpadding="1" cellspacing="1" border="0">
			<tr>
				<td><input type="button" id="btnQuery" value="查询"
					class="inputButton" /></td>
			    <td><input type="button" id="btnBack" value="退 回"
					 class="inputButton"/></td>		
			    <td><input type="button" id="btnBreak" value="返 回"
					 class="inputButton"/></td>		
			</tr>
		</table>
	   <table cellpadding="1" cellspacing="1">
			<tr>
			    <td>目录名称：</td>
				<td><input type="text" name="directoryName" id="directoryName"  autocomplete="off" class="inputText" /></td>
				<td>材料主题：</td>
				<td><input type="text" name="title" id="title"  autocomplete="off" class="inputText" /></td>
				<td>文件类型：</td>
				<td><select id="type" name="type" class="selectList">
			         	<option value="">全部</option>
						<option value="1">上交</option>
						<option value="2">个人</option>
				       </select></td>&nbsp;&nbsp;
			</tr>
		</table>	
		
	
        <table id="dg" class="easyui-datagrid "  style="width:100%;"
		   data-options="pagination:true,collapsible:true,method:'post',remoteSort:true,striped:true"> 
		<thead>
			<tr>
				<th data-options="field:'projectMaterialId',checkbox:true,width:60,align:'left'"></th>
			    <th data-options="field:'projectName',sortable:true,nowrap:true,width:300,align:'left'">项目名称</th>
				<th data-options="field:'directoryName',sortable:true,nowrap:true,width:300,align:'left'">目录名称</th>
				<th data-options="field:'title',sortable:true,nowrap:true,width:300,align:'left',formatter: formater">材料主题</th>
				<th data-options="field:'xm',sortable:true,nowrap:true,width:200,align:'left'">材料负责人</th>
				<th data-options="field:'state',sortable:true,nowrap:true,width:300,align:'left',formatter: formstates">状态</th>
				<th data-options="field:'type',sortable:true,nowrap:true,width:200,align:'left',formatter: formatType">文件类型</th>
			    <th data-options="field:'date',sortable:true,nowrap:true,width:200,align:'left',formatter: formatDate">材料时间</th>
			    <th data-options="field:'name',nowrap:true,width:300,align:'left',sortable:true">材料创建人</th>
			    <th data-options="field:'projectMaterialAddDate',sortable:true,nowrap:true,width:200,align:'left',formatter: formatDate">创建时间</th>
			    <th data-options="field:'xz',width:600,align:'left',sortable:true">附件</th>
			</tr>
		</thead>
	</table>
	</form>
	
	
    
  
	
		 <script type="text/javascript">
		 
		   function formatDate(value){
			   var date=new Date(value);
				var y = date.getFullYear();
				var m = date.getMonth()+ 1;
				var d = date.getDate();
				var h= date.getHours();       //获取当前小时数(0-23)
				var mm= date.getMinutes();     //获取当前分钟数(0-59)
				var s= date.getSeconds();     //获取当前秒数(0-59)
				return y +'-'+(m <10?('0'+ m):m)+'-'+(d <10?('0'+ d):d)+'';
			}
	    
		 
		   function formstates(value,row, index){
		    	if(value==0){
		    		 return  value="保存"
		    	}else if(value==1){
		    		 return value="已提交"
		    	}else if(value==2){
		    		 return value="退回"
		    	}
			}    
		   
		   function formatType(value,row, index){
		    	if(value==1){
		    		 return  value="上交"
		    	}else if(value==2){
		    		 return value="个人"
		    	}
			}    
		   
		     function formater(value, row, index) {
		             return "<a href='${basePath}/projectmaterial/projecti_details?id=" + row.projectMaterialId+"&projectId=${id}'>" + value + "</a>"; 
	         }
		 
			$(document).ready(
							function() {
	                             $('#dg').datagrid({
	                            	 url:'${basePath}/projectmaterial/projectmaterial_List?id='+${id},
	                            	 nowrap:false,
								 onSortColumn :function(sort,order){
								   var _sort=sort;
								   var _order=order;
								   var options=$('#dg').datagrid('getPager').data("pagination").options;
								   var page=options.pageNumber;
								   var pageSize=options.pageSize;
								   window.setTimeout(function(){
									   $.post("${basePath}/projectmaterial/projectmaterial_List?id="+${id},{orderFlag:_order,orderField:_sort,
										   title: $('#title').val(),
										   directoryName: $('#directoryName').val(),
										   type: $('#type').val()
									   },
												function(data){
												  $('#dg').datagrid("loadData",data); 
											   });
											   },100);  
								   },
								   rowStyler: function(index,row){
								   },
	                          });
	                             
	                 			
								//返回
								$('#btnBreak').click(function() {
									     window.location.href = "${basePath}/project/index";
								});
								
								
								//查询
								$('#btnQuery')
										.click(
												function() {
													$('#dg').datagrid('load',{
														   title: $('#title').val(),
														   directoryName: $('#directoryName').val(),
														   type: $('#type').val()
													});
												});
								
								
								$('#btnBack').click(function() {
						               $("#idList").val("");
										var count = 0;
										var idList = new Array();
									    var sels = $("#dg").datagrid("getSelections");
								    	for(var i in sels){
								    		idList.push(sels[i].projectMaterialId);
								    		count++;
								    	}
								       if (count == 0) {
												layer.alert("您至少选择一条退回记录信息", {icon: 3});
												return false;
										}else{
											  layer.confirm("您是否确定要退回当前选中数据信息", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
												    $("#idList").val(idList);
												     document.Form.action = "${basePath}/projectmaterial/auditList?id="+$("#id").val();
												     document.Form.submit();
											  },function(index){
													layer.close(index);
											  });
									    }
							    });
		         });
			
		    if("${msg}"!=""){
		       layer.alert("${msg}", {icon: 6});
		     } 
		</script>
</body>
</html>
